#pragma once

#include <irrlicht.h>


class CSampleSceneNode : public irr::scene::ISceneNode
{
	irr::core::aabbox3d<irr::f32> Box;
	irr::video::S3DVertex Vertices[4];
	irr::video::SMaterial Material;
public:

	CSampleSceneNode(irr::scene::ISceneNode* parent, irr::scene::ISceneManager* mgr, irr::s32 id)
		: irr::scene::ISceneNode(parent, mgr, id)
	{
		Material.Wireframe = false;
		Material.Lighting = false;

		Vertices[0] = irr::video::S3DVertex(0,0,10, 1,1,0,
			irr::video::SColor(255,0,255,255), 0, 1);
		Vertices[1] = irr::video::S3DVertex(10,0,-10, 1,0,0,
			irr::video::SColor(255,255,0,255), 1, 1);
		Vertices[2] = irr::video::S3DVertex(0,20,0, 0,1,1,
			irr::video::SColor(255,255,255,0), 1, 0);
		Vertices[3] = irr::video::S3DVertex(-10,0,-10, 0,0,1,
			irr::video::SColor(255,0,255,0), 0, 0);
		Box.reset(Vertices[0].Pos);
		for (irr::s32 i=1; i<4; ++i)
			Box.addInternalPoint(Vertices[i].Pos);
	}
	virtual void OnRegisterSceneNode()
	{
		if (IsVisible)
			SceneManager->registerNodeForRendering(this);

		ISceneNode::OnRegisterSceneNode();
	}
	virtual void render()
	{
		irr::u16 indices[] = {   0,2,3, 2,1,3, 1,0,3, 2,0,1  };
		irr::video::IVideoDriver* driver = SceneManager->getVideoDriver();

		driver->setMaterial(Material);
		driver->setTransform(irr::video::ETS_WORLD, AbsoluteTransformation);
		driver->drawVertexPrimitiveList(&Vertices[0], 4, &indices[0], 4, irr::video::EVT_STANDARD, irr::scene::EPT_TRIANGLES, irr::video::EIT_16BIT);
	}
	virtual const irr::core::aabbox3d<irr::f32>& getBoundingBox() const
	{
		return Box;
	}

	virtual irr::u32 getMaterialCount() const
	{
		return 1;
	}

	virtual irr::video::SMaterial& getMaterial(irr::u32 i)
	{
		return Material;
	}   
};



class CustomSceneNode
{
public:
	CustomSceneNode(void);
	~CustomSceneNode(void);

	void show(irr::IrrlichtDevice* irrDevice);
};

